﻿using Estsh.Core.Base;
using Estsh.Core.Model.Extend;
using Estsh.Core.Models;
using Estsh.Core.Repositories;
using Estsh.Core.Model.Extend.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estsh.Core.Wms.IRepositories
{
    public interface IMoveOrderRepository : IBaseRepository<WmsMoveHeader>
    {
        /// <summary>
        /// 获取正在创建中的单据
        /// </summary>
        /// <returns></returns>
        List<WmsMoveHeader> GetCreateingList();
        /// <summary>
        /// 根据单据类型获取此类型待处理的单据列表,如果单据类型为空，则获取全部类型
        /// </summary>
        /// <returns></returns>
        List<WmsMoveHeader> GetMoveOrderList(int? orderType,string orderNo);

        /// <summary>
        /// 根据单据号获取单据明细列表
        /// </summary>
        /// <returns></returns>
        List<WmsMoveDetail> GetMoveDetailList(string orderNo);
        /// <summary>
        /// 根据单据号和零件号获取单据明细
        /// </summary>
        /// <returns></returns>
        WmsMoveDetail GetMoveDetail(string orderNo, string partNo);
        /// <summary>
        /// 根据单据号获取单据条码列表
        /// </summary>
        /// <returns></returns>
        List<WmsMoveSn> GetMoveSnList(string orderNo);
        /// <summary>
        /// 根据单据号和箱条码获取单据条码
        /// </summary>
        /// <returns></returns>
        WmsMoveSn GetMoveSn(string orderNo, string cartonNo);
        /// <summary>
        /// 提交单据
        /// </summary>
        /// <param name="orderNo"></param>
        /// <param name="loginId"></param>
        /// <returns></returns>
        bool OrderComplete(string orderNo, string loginId);
        /// <summary>
        /// 处理扫描的箱条码
        /// </summary>
        /// <param name="cartonInfo"></param>
        /// <param name="moveDetail"></param>
        /// <returns></returns>
        string DoCarton(SysStock_Extend cartonInfo, string orderNo, int orderType,
            string loginId, WmsMoveDetail moveDetail);

        /// <summary>
        /// 提交单据-单据创建
        /// </summary>
        /// <param name="orderNo"></param>
        /// <param name="loginId"></param>
        /// <returns></returns>
        bool OrderCreated(string orderNo, string loginId);
        /// <summary>
        /// 创建单据--大件拉动
        /// </summary>
        /// <param name="cartonInfo"></param>
        /// <param name="moveDetail"></param>
        /// <returns></returns>
        void CreatePullOrder(string loginId, List<WmsMoveDetail> moveDetails);


        /// <summary>
        /// 大件拣选
        /// </summary>
        /// <param name="loginId"></param>
        /// <param name="moveDetails"></param>
        /// <param name="pullingGroup"></param>
        void CreatePullPickOrder(string loginId, List<WmsPullingOrderDetail> moveDetails, WmsPullingGroup pullingGroup);


        /// <summary>
        /// 安全库存拉动
        /// </summary>
        /// <param name="loginId"></param>
        /// <param name="moveDetails"></param>
        void CreateSafetyPullOrder(string loginId, List<SysLocatePart> moveDetails);

        void ChangeSafety(List<WmsMoveHeader> header);
        /// <summary>
        /// 获取库存数量（根据零件+库区）
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="zoneId"></param>
        /// <returns></returns>
        public decimal GetPickQty(int partId, int zoneId);
        /// <summary>
        /// 创建单据--大件拉动补充
        /// </summary>
        /// <returns></returns>
        public void CreatePullOrder(string loginId, List<WmsMoveDetail> moveDetails, SysPdlineZone pdlineZone);

        /// <summary>
        /// 根据扫描的箱条码获取移动单据条码信息
        /// </summary>
        /// <param name="cartonNo"></param>
        /// <returns></returns>
        public WmsMoveSn GetMovesnInfo(string cartonNo);

    }
}
